
import java.util.ArrayList;
import processing.core.PImage;

/**
 *
 * @author admindev
 */
public class Player
{
    public Jeu program;
    
    protected int crystals;
    protected int maxCrystals;
    protected int lvlCrystals;
    
    protected int quantitySoldiers;
    protected int maxQuantitySoldiers;
    protected int lvlQuantitySoldiers;
    
    protected int gas;
    protected int maxGas;
    protected int lvlGas;

    protected String namePlayer;
    
    public Player(Jeu program)
    {
        this.namePlayer = "Player 1";
        this.program = program;
        
        this.crystals = 500;
        this.maxCrystals = 1500;
        this.lvlCrystals = 1;
        
        this.quantitySoldiers = 0;
        this.maxQuantitySoldiers = 35;
        this.lvlQuantitySoldiers = 0;
        
        this.gas = 0;
        this.maxGas = 200;
        this.lvlGas = 0;
    }
    
    public void displayRessources()
    {
        PImage affiche_crystal_hud = program.loadImage("ImageHub/crystal.png");
        PImage affiche_gas_hud = program.loadImage("ImageHub/gas.png");
        
        program.image(affiche_crystal_hud,1050,595,30,30);
        program.image(affiche_gas_hud,1050,635,30,30);
        
        program.text(intToString(crystals)+"/",1090,595,45,45);
        program.text(intToString(maxCrystals),1090,610,45,45);
        program.text("lvl: "+intToString(lvlCrystals),1090,620,45,45);
        
        program.text(intToString(gas)+"/",1090,635,45,45);
        program.text(intToString(maxGas),1090,655,45,45);
        program.text("lvl: "+intToString(lvlGas),1090,670,45,45);
        
    }
    
    public void upRessources()
    {
        int baseCrystals = getCrystals();
        int baseGas = getGas();
        int crystalsUp = crystalsPerSec();
        int gasUp = gasPerSec();
        if( crystals < maxCrystals )
        {
            setCrystals(baseCrystals+crystalsUp);
            if( crystals > maxCrystals)
                setCrystals(maxCrystals);
        }
        if( gas < maxGas )
        {
            setGas(baseGas+gasUp);
            if( gas > maxGas)
                setGas(maxGas);
        }
    }
    
    public int crystalsPerSec()
    {
        switch (lvlCrystals)
        {    
            case 0:
                return 0;
            case 1:
                return 8;
            case 2:
                return 10;
            case 3:
                return 16;
            case 4:
                return 22;
            case 5:
                return 30;
            default:
                return 8;
        }
       
    }

    public int gasPerSec()
    {
        switch (lvlGas)
        {    
            case 0:
                return 0;
            case 1:
                return 8;
            case 2:
                return 10;
            case 3:
                return 16;
            case 4:
                return 22;
            case 5:
                return 30;
            default:
                return 8;
        }
    }
    
    public void upMaxCrystals()
    {
        switch (lvlCrystals)
        {    
            case 0:
                setMaxCrystals(1500);
            case 1:
                setMaxCrystals(1500);
            case 2:
                setMaxCrystals(1800);
            case 3:
                setMaxCrystals(2000);
            case 4:
                setMaxCrystals(2500);
            case 5:
                setMaxCrystals(3000);
            default:
                setMaxCrystals(1500);
        }
    }
    
    public void upMaxGas()
    {
        switch (lvlCrystals)
        {    
            case 0:
                setMaxCrystals(1500);
            case 1:
                setMaxCrystals(1500);
            case 2:
                setMaxCrystals(1800);
            case 3:
                setMaxCrystals(2000);
            case 4:
                setMaxCrystals(2500);
            case 5:
                setMaxCrystals(3000);
            default:
                setMaxCrystals(1500);
        }
    }
         
    public void upLvlCrystals()
    {
        setLvlCrystals(lvlCrystals+1);
        upMaxCrystals();
    }
    
    public String intToString(int value)
    {
        return ""+value;
    }
    
    public void addQuantitySoldiers(int quantity)
    {
        int baseCrystals = getCrystals();
        int baseGas = getGas();
    }
    

    ////////////////////////////////////////////////////////////////////////
    ////////                     Getter/ Setter                     ////////
    ///////////////////////////////////////////////////////////////////////
    
    public int getCrystals()
    {
        return crystals;
    }

    public void setCrystals(int crystals)
    {
        this.crystals = crystals;
    }

    public int getMaxCrystals()
    {
        return maxCrystals;
    }

    public void setMaxCrystals(int maxCrystals)
    {
        this.maxCrystals = maxCrystals;
    }

    public int getLvlCrystals()
    {
        return lvlCrystals;
    }

    public void setLvlCrystals(int lvlCrystals)
    {
        this.lvlCrystals = lvlCrystals;
    }
    
    public int getQuantitySoldiers()
    {
        return quantitySoldiers;
    }

    public void setQuantitySoldiers(int quantitySoldiers)
    {
        this.quantitySoldiers = quantitySoldiers;
    }

    public int getMaxQuantitySoldiers()
    {
        return maxQuantitySoldiers;
    }

    public void setMaxQuantitySoldiers(int maxQuantitySoldiers)
    {
        this.maxQuantitySoldiers = maxQuantitySoldiers;
    }

    public int getLvlQuantitySoldiers()
    {
        return lvlQuantitySoldiers;
    }

    public void setLvlQuantitySoldiers(int lvlQuantitySoldiers)
    {
        this.lvlQuantitySoldiers = lvlQuantitySoldiers;
    }

    public int getGas()
    {
        return gas;
    }

    public void setGas(int gas)
    {
        this.gas = gas;
    }


    public int getMaxGas()
    {
        return maxGas;
    }

    public void setMaxGas(int maxGas)
    {
        this.maxGas = maxGas;
    }

    public int getLvlGas()
    {
        return lvlGas;
    }

    public void setLvlGas(int lvlGas)
    {
        this.lvlGas = lvlGas;
    }

    public String getNamePlayer()
    {
        return namePlayer;
    }

    public void setNamePlayer(String namePlayer)
    {
        this.namePlayer = namePlayer;
    }
    
}
